/******************************************************************
 * Parser -
 * Fabrice Aubert
*/



#ifndef INC_PARSER_H
#define INC_PARSER_H


#include <stdlib.h>
#include <string>
#include <map>
#include "Lexer.h"
#include <fstream>
#include <vector>


namespace fileIO {




class Parser {
  Lexer lex;

protected:
  std::map<std::string,Token> mots;
  std::string _filename;

public:
  Parser(std::string nom,int mode=0);
  virtual ~Parser();

  void setCommentLine(std::string s);
  void setSeparator(std::string s);

  Lexer &lexer() {
    return lex;
  }

  virtual void skipToken();
  virtual void skipMot();
  virtual void skipMotSameLine();

  void analyse(int debut=0,int fin=0);

  int readInteger();
  int readNextInteger();
  double readDouble();
  double readNumber();
//    std::string lireMot();
  Token token() {
    return lex.token();
  }
  std::string sToken() {
    return lex.chaine();
  }

  std::string lastComment() {
    return lex.comment();
  }

  int iToken();
  double dToken();
  unsigned int cToken();

  void lireLigne() {
    lex.lireLigne();
  }
  bool isOk();
  bool isNumber();
  bool isOpen();

  void close();

  void read(const std::string &s);
  bool readString(const std::string &s);

  std::string filename();

};








} // namespace MM_PARSER

#endif
